package com.kkelectronics.w2b.devplugin.codegenerator.model;

import java.util.HashSet;
import java.util.Set;

import org.eclipse.jdt.core.dom.Javadoc;
import org.eclipse.jdt.core.dom.Name;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.Type;

public class Field {

	private Javadoc javadoc;
	private SimpleName name;
	private Type type;
	private Set<Name> importTypes = new HashSet<Name>();

	public Javadoc getJavadoc() {
		return javadoc;
	}

	public void setJavadoc(Javadoc javadoc) {
		this.javadoc = javadoc;
	}

	public SimpleName getName() {
		return name;
	}

	public void setName(SimpleName name) {
		this.name = name;
	}

	public Type getType() {
		return type;
	}

	public void setType(Type type) {
		this.type = type;
	}

	public Set<Name> getImportTypes() {
		return importTypes;
	}

	public void addImportType(Name typeQualifiedName) {
		if (importTypes.isEmpty()) {
			this.importTypes.add(typeQualifiedName);
		} else {
			for (Name name : importTypes) {
				if (name.toString().equals(typeQualifiedName.toString()))
					continue;
				this.importTypes.add(typeQualifiedName);
			}
		}
	}

	@Override
	public String toString() {
		return "Field [javadoc=" + javadoc + ", name=" + name + ", type=" + type + ", importTypes=" + importTypes + "]";
	}

}
